<template>
  <div>
    <el-dropdown>
      <span style="color: #fff">
        <svg-icon icon-class="language" />
      </span>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item
            :disabled="$i18n.locale === 'zh'"
            @click.native="changeLang('zh')"
          >中文</el-dropdown-item>
          <el-dropdown-item
            :disabled="$i18n.locale === 'en'"
            @click.native="changeLang('en')"
          >en</el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>
<script>
import jsCookie from 'js-cookie'
export default {
  name: 'Lang',
  methods: {
    changeLang(code) {
      this.$i18n.locale = code
      jsCookie.set('lang', code)
      this.$router.go(0)
    }
  }
}
</script>
<style></style>
